import { fromJS } from 'immutable';
import * as actionTypes from './actionTypes';

const defaultState = fromJS({
  title: '',
  content: ''
})

export default (state = defaultState, action) => {
  switch(action.type) {
    case actionTypes.CHANGE_DETAIL_DATA:
      return changeDetailData(state, action);
    default:
      return state;
  }
}

const changeDetailData = (state, action) => {
  return state.merge({
    title: fromJS(action.title),
    content: fromJS(action.content)
  })
}